//
//  CalendarView.m
//  Conferences
//
//  Created by Mason Mei on 5/13/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "CalendarView.h"

@implementation CalendarView
@synthesize timeLine = _timeLine, sceduleContent = _sceduleContent;

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

-(id)initWithContent:(NSArray *)contents{
    CGRect frame = CGRectMake(0, 0, 480, 600);
    self = [super initWithFrame:frame];
    if(self){
        //Initialization code here;
        [self initTimeLine];
        [self initScheduleContent];
        [self addSubview:_timeLine];
        [self addSubview:_sceduleContent];
    }
    return self;
}

-(void)initTimeLine{
    CGRect frame =  CGRectMake(0, 0, 40, 600);
    _timeLine = [[UIView alloc]initWithFrame:frame];
    _timeLine.backgroundColor = [UIColor blackColor];
    int count = 0;
    for (int i = 8; i <= 17; i++) {
        int hour = i;
        NSString *dayfix = [NSString stringWithFormat:@"am"];
        if(hour > 13) {
            hour -= 12;
            dayfix = [NSString stringWithFormat:@"pm"];
        }
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 45 + 60 * count, 26, 24)];
        label.text = [NSString stringWithFormat:@"%2d:00   %@",hour, dayfix];
        label.numberOfLines = 2;
        label.font = [UIFont systemFontOfSize:10];
        label.textAlignment = UITextAlignmentRight;
        label.textColor = [UIColor whiteColor];
        label.backgroundColor= [UIColor clearColor];
        
        UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(36, 50 + 60 * count, 4, 12)];
        label2.text = [NSString stringWithFormat:@"-"];
        label2.font = [UIFont systemFontOfSize:10];
        label2.textAlignment = UITextAlignmentRight;
        label2.textColor = [UIColor whiteColor];
        label2.backgroundColor= [UIColor clearColor];
        
        [_timeLine addSubview:label];
        [_timeLine addSubview:label2];
        
        count ++;
    }
//    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 30, 25, 24)];
//    label.text = [NSString stringWithFormat:@"8:00 am"];
//    label.numberOfLines = 2;
//    label.font = [UIFont systemFontOfSize:10];
//    label.textAlignment = UITextAlignmentRight;
//    label.textColor = [UIColor whiteColor];
//    label.backgroundColor= [UIColor clearColor];
//    
//    UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(36, 35, 4, 12)];
//    label2.text = [NSString stringWithFormat:@"-"];
//    label2.font = [UIFont systemFontOfSize:10];
//    label2.textAlignment = UITextAlignmentRight;
//    label2.textColor = [UIColor whiteColor];
//    label2.backgroundColor= [UIColor clearColor];
//    
//    [_timeLine addSubview:label];
//    [_timeLine addSubview:label2];
}
-(void)initScheduleContent{
    CGRect frame =  CGRectMake(40, 0, 400, 600);
    _sceduleContent = [[UIView alloc]initWithFrame:frame];
    _sceduleContent.backgroundColor = [UIColor grayColor];
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
